#include <iostream>
#include <vector>
using namespace std;
struct TreeNode {
	int val;
	TreeNode *left;
	TreeNode *right;
	TreeNode() : val(0), left(nullptr), right(nullptr) {}
	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
	TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};
class Solution{
private:
	void traversal(TreeNode* node,vector<int>& path,vector<string>& result){
		if(node == nullptr) return;
		path.push_back(node->val);
		if(node->left == nullptr && node->right == nullptr){
			string spath;
			for(int i = 0;i < path.size()-1;i++){
				spath += to_string(path[i]) + "->";
			}
			spath += to_string(path[path.size()-1]);
			result.push_back(spath);
			return;
		}
		if(node->left){
			traversal(node->left,path,result);
			path.pop_back();
		}
		if(node->right){
			traversal(node->right,path,result);
			path.pop_back();
		}
	}
	
public:
	vector<string> binaryTreePaths(TreeNode* root) {
		vector<string> result;
		vector<int> path;
		traversal(root,path,result);
		return result;
	}
};


int main(){
	return 0;
}
